﻿Public Class Packets

    Public Shared Sub charDisplay(ByVal handler As Handler, ByVal userid As Integer)
        Dim pc As New PacketCreator(handler)
        pc.addInt(&HF3)
        pc.addInt(PacketHandler.auth)
        Dim list As List(Of Character) = MySQL.getCharacters(userid)
        pc.addInt(list.Count)

        Dim c As Character
        Dim lastSlot As Integer = 0
        Dim i As Integer = 0

        For Each obj As Object In list
            c = obj
            pc.addInt(c.slot)
            pc.addInt(1)
            pc.addInt(c.mapID)
            pc.addInt(&HC)
            pc.addString(c.name)
            pc.addFloat(c.x)
            pc.addFloat(c.y)
            pc.addFloat(c.z)
            pc.addInt(c.id)
            pc.addInt(0)
            pc.addInt(0)
            pc.addInt(0)
            pc.addInt(0)
            pc.addInt(c.hairstyle)
            pc.addInt(c.haircolor)
            pc.addInt(c.face)
            pc.addByte(c.gender)
            pc.addInt(c.job)
            pc.addInt(c.level)
            pc.addInt(0)
            pc.addInt(c.str)
            pc.addInt(c.sta)
            pc.addInt(c.dex)
            pc.addInt(c.intt)
            pc.addInt(0)
            Dim equips As New List(Of Integer)
            pc.addInt(MySQL.getEquips(c.id, equips))
            Dim id As Integer
            For Each myObj As Object In equips
                id = myObj
                pc.addInt(id)
                id = Nothing
            Next
            lastSlot = c.slot
            c = Nothing
            i += 1
        Next
        pc.addInt(list.Count)
        For t As Integer = 0 To list.Count Step t + 1
            pc.addInt(t)
            pc.addInt(2)
        Next
        pc.send()
    End Sub

    Public Shared Sub loginError(ByVal handler As Handler, ByVal errorid As Integer)
        Dim pc As New PacketCreator(handler)
        pc.addInt(&HFE)
        pc.addInt(errorid)
        pc.send()
    End Sub

    Public Shared Sub sendPing(ByVal handler As Handler, ByVal ping As Integer)
        Dim pc As New PacketCreator(handler)
        pc.addInt(&H14)
        pc.addInt(ping)
        pc.send()
    End Sub

    Public Shared Sub sendAuth(ByVal handler As Handler, ByVal auth As Integer)
        Dim pc As New PacketCreator(handler)
        pc.addInt(&HB)
        pc.addInt(auth)
        pc.send()
    End Sub

End Class

